home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6775 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: cymbal.aix.calpoly.edu!not-for-mail
  2. From: dstubbs@cymbal.aix.calpoly.edu (Dan Stubbs)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Limit on #bytes inside of struct?
  5. Date: 14 Feb 1996 17:28:28 -0800
  6. Organization: California Polytechnic State University, San Luis Obispo
  7. Message-ID: <4fu27s$2i23@cymbal.aix.calpoly.edu>
  8. References: <4feg1d$d4g@cville-srv.wam.umd.edu> <4ffohq$1gb@mordred.gatech.edu> <4ffun7$1l4l@cymbal.aix.calpoly.edu> <311F15D8.78D1@zess.uni-siegen.de>
  9. NNTP-Posting-User: dstubbs@cymbal.aix.calpoly.edu
  10.  
  11. In article <311F15D8.78D1@zess.uni-siegen.de>,
  12. Markus Becker  <becker@zess.uni-siegen.de> wrote:
  13. >Dan Stubbs wrote:
  14. >> Here is a specific program to test the above suggestions.
  15. >
  16. >No it isn't, see below.
  17. >
  18. >>    typedef struct {
  19. >>       int the_array[50000];
  20. >>    } struct_type;
  21. >> 
  22. >
  23. >This way, you don't put the 50K numbers in the struct, but only
  24. >a pointer to them. Should be at most 4 bytes.
  25. >
  26. >--
  27. >Markus Becker                
  28.  
  29. I wonder if you tried this? I applied the sizeof operator to both
  30. the type and to instances of the type and got 200000 for the size.
  31. This was for a half dozen different compiler/hardware pairs.
  32.  
  33. So, if you know of a system that actually stores a pointer to the
  34. array as the struct, instead of the array, it would be interesting
  35. to know which it is.
  36.  
  37. To be honest, I don't see any advantage to storing the pointer instead
  38. of the array. Every instance of struct_type will have to have its own
  39. array to which it points. Why complicate things by setting the array
  40. somewhere else and accessing it indirectly (all behind the scenes).
  41.  
  42. It would be different if all instances of struct_type could share
  43. one array--but alas they can't.
  44.  
  45.  
  46.  
  47.